package com.constructor;

public class SuperTest03{
	public static void main(String[] args){
 
		CreditAccount ca1 = new CreditAccount(); //调用无参构造
		System.out.println(ca1.getActno() + "," +
        ca1.getBalance() + "," + ca1.getCredit()); //null,0.0,0.0
 
		CreditAccount ca2 = new CreditAccount("1111", 10000.0, 0.999);//调用有参构造
		System.out.println(ca2.getActno() + "," + 
        ca2.getBalance() + "," + ca2.getCredit()); //1111,10000.0,0.999
 
	}
}
 
// 账户
class Account extends Object{
	// 属性
	private String actno;
	private double balance;
 
	// 构造方法
	public Account(){ //对于无参构造，默认会调用super()；并且给实列变量赋上缺省初始值
		//super();
		//this.actno = null;
		//this.balance = 0.0;
	}
	public Account(String actno, double balance){
		// super();
		this.actno = actno;
		this.balance = balance;
	}
 
	// setter and getter
	public void setActno(String actno){
		this.actno = actno;
	}
	public String getActno(){
		return actno;
	}
	public void setBalance(double balance){
		this.balance = balance;
	}
	public double getBalance(){
		return balance;
	}
}
 
// 信用账户
class CreditAccount extends Account{
 
	// 属性：信誉度（诚信值）
	// 子类特有的一个特征，父类没有。
	private double credit;
 
//重点在这里-------------------------------写上有参构造方法
	// 分析以下程序是否存在编译错误？？？？
	public CreditAccount(String actno, double balance, double credit){
 
		// 直接访问不行，继承过来的私有的属性，只能通过setter和getter方法进行访问
		/*
		this.actno = actno;
		this.balance = balance;
		*/
 
		// 以上两行代码在恰当的位置，正好可以使用：super(actno, balance);
		// 通过子类的构造方法调用父类的构造方法。
		super(actno, balance); //调用父类的构造方法
		this.credit = credit;
	}
 
 
	// 提供无参数的构造方法
	public CreditAccount(){ //对于无参构造，默认会调用super()；并且给实列变量赋上缺省初始值
 
		//super();
		//this.credit = 0.0;
	}
 
	// setter and getter方法
	public void setCredit(double credit){
		this.credit = credit;
	}
	public double getCredit(){
		return credit;
	}
	
}